package com.upic.serviceImpl;

import com.upic.po.jurisdiction.Operator;
import com.upic.repository.OperatorRepository;
import com.upic.service.OperatorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by zhubuqing on 2018/2/7.
 */
@Service("operatorService")
public class OperatorServiceImpl implements OperatorService {
    @Autowired
    private OperatorRepository operatorRepository;

    @Override
    public Operator saveOperator(Operator operator) {
        return operatorRepository.save(operator);
    }

    @Override
    public String deleteOperator(long operatorId) {
        operatorRepository.delete(operatorId);
        return "SUCCESS";
    }

    @Override
    public Page<Operator> searchOperator(Pageable pageable) {
        return operatorRepository.findAll(pageable);
    }

    @Override
    public List<Operator> searchOperator() {
        return operatorRepository.findAll();
    }

    @Override
    public Operator findOne(long operatorId) {
        return operatorRepository.findOne(operatorId);
    }

    @Override
    public Operator updateOperator(Operator operator) {
        return operatorRepository.saveAndFlush(operator);
    }
}
